<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="schronisko.*,Users.*,java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../styles/message.css">
<title>Stare wiadomosci</title>

</head>
<body>
<% if(session.getAttribute("ID") != null){ %>
<a href = "../admin/messages.jsp"> Powrot do panelu</a><br><br>
<center>
<h1>Archiwum wiadomosci</h1>
<%
if ((Integer) session.getAttribute("type") == 2 || (Integer) session.getAttribute("type") == 3) {
response.setContentType("text/html");
if((Integer)session.getAttribute("deleted_msg") == 1) {
	out.println("Pomyslnie usunieto wiadomosc<br><br><br>");
	session.setAttribute("deleted_msg", 0);
}
else if ((Integer) session.getAttribute("mark_msg0") == 1) {
	out.println("Oznaczono jako nieprzeczytana<br><br><br>");
	session.setAttribute("mark_msg", 0);
}
Queries q = new Queries();
ResultSet r = q.getMessages(1);
while(r.next()) {
	int ID= r.getInt("ID_msg");
%>
<div class="table">
<div class='ID'><% out.println(ID); %></div>
<div class='username'><% out.println(r.getString("username")); %></div>
<div class='email'><% out.println(r.getString("email")); %></div>
<div class='topic'><% out.println(r.getString("topic")); %></div>
<div class='data'><% out.println(r.getString("msg")); %></div>
<div class='date'><% out.println(r.getDate("date")); %></div>
<div class='delete'>
				<form name='delete' action='../Message' method='post'>
					<input id='id' name='id' type='hidden'
						value="<% out.print(ID); %>"> <input id='type'
						name='type' type='hidden' value='del'> <input
						type='submit' value='Usun'>
				</form>
			</div>
			<div class='reply'>
				Archiwum
			</div>
			<div class='mark'>
				<form name='mark' action='../Message' method='post'>
					<input id='type' name='type' type='hidden' value='mark0'> <input
						id='id' name='id' type='hidden' value="<% out.print(ID); %>">
					<input type='submit' value='Oznacz jako nieprzeczytana'>
				</form>
			</div>
</div>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<%
}
}
}
else {
	out.println("<div class='menu'><b>Sesja wygasla.</b><br> Za 3 sec nastapi przeniesienie do strony logowania <br> Kliknij, jesli nie zadziala:<br> <a href = '../index.jsp'> Wroc do strony glownej</a></div>");
	response.setHeader("Refresh", "3; URL=../index.jsp");
}
%>
</center>
</body>
</html>